package com.fastCms.business.frame.plugins.email;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;

import javax.annotation.Resource;

/**
 * 发送邮件相关参数
 */

@Data
@Configuration
public class EmailBeanConfig {

    @Value("${spring.mail.from}")
    private String emailFrom;

    @Value("${spring.mail.companyName}")
    private String companyName;

    @Resource
    private JavaMailSender javaMailSender;

    @Bean
    public EmailProperties mailProperties() {
        EmailProperties mailProperties = new EmailProperties();
        mailProperties.setEmailFrom(emailFrom);
        mailProperties.setMailSender(javaMailSender);
        mailProperties.setCompanyName(companyName);
        return mailProperties;
    }

}
